/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jsf;

import ejb.VentaFacade;
import entity.Venta;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author mbvierci
 */
@ManagedBean
@RequestScoped
public class VentaBean {
    
     @EJB
    private VentaFacade ventaFacade;
    private Venta venta = new Venta();
    private List<Venta> ventas;

    /**
     * Creates a new instance of VentaBean
     */
    public VentaBean() {
    }
    
     public Venta getVenta() {
        return venta;
    }

    public void setVenta(Venta venta) {
        this.venta = venta;
    }
    
    public VentaFacade getVentaFacade() {
        return ventaFacade;
    }

    public void setVentaFacade(VentaFacade ventaFacade) {
        this.ventaFacade = ventaFacade;
        ventas = ventaFacade.findAll();
    }

    public List<Venta> getVentas() {
        return ventas;
    }

    public void setVentas(List<Venta> ventas) {
        this.ventas = ventas;
    }
    
    public void crearVenta(){
        ventaFacade.create(venta);
        ventas.add(venta);
        venta = new Venta();
    }
}
